Public Class MainForm

    Private Sub DisplayControl(ByVal hdrCtrl As TD.Eyefinder.HeaderControl, ByRef ctrl As UserControl)
        Dim exCtrl As UserControl = Nothing
        For Each c As UserControl In hdrCtrl.Controls
            If c.Name = ctrl.Name Then
                exCtrl = c
                Exit For
            End If
        Next

        If exCtrl Is Nothing Then
            hdrCtrl.Controls.Add(ctrl)
            ctrl.Dock = DockStyle.Fill
        Else
            ctrl = exCtrl
        End If

        ctrl.BringToFront()
        If ctrl.Tag IsNot Nothing Then hdrCtrl.Text = ctrl.Tag
    End Sub

    Private Sub searchNamesLnik_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles searchNamesLnik.LinkClicked
        Dim req As New NavigationRequest
        req.Type = NavigationType.SearchNames
        DoNavigate(Nothing, req)
    End Sub

    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
    End Sub

    Protected Sub DoNavigate(ByVal sender As UserControl, ByVal req As NavigationRequest)
        If req.Type = NavigationType.SearchNames Then
            Dim ctrl As New NameSearch
            AddHandler ctrl.NavigateToEvent, AddressOf Me.DoNavigate
            DisplayControl(nameHeaderCtrl, ctrl)
        ElseIf req.Type = NavigationType.EditName Then
            Dim ctrl As New EditNameCtrl
            AddHandler ctrl.NavigateToEvent, AddressOf Me.DoNavigate
            DisplayControl(nameHeaderCtrl, ctrl)
            ctrl.LoadName(New Guid(req.Id))
        End If
    End Sub


End Class